package package06章_面向对象编程_基础._05oop.exer1_methodMore._03_valueTransfer;

/**
 * @ClassName: e_6_10valueTransferTest
 * @Author 86132
 * @Package package06章_面向对象编程_基础.oop05.exer1_methodMore._03_valueTransfer
 * @Date 2024/2/13 11:34
 * @description:
 */
public class e_6_10valueTransferTest {
    public static void main(String[] args) {
        //1. 基本数据类型的局部变量
        int m = 10;
        int n = m;  //传递的是数据值

        System.out.println("m = " + m + ", n = " + n);

        m++;

        System.out.println("m = " + m + ", n = " + n);

        //2. 引用数据类型的局部变量
        //2.1 数组类型
        int[] arr1 = new int[]{1, 2, 3, 4, 5};
        int[] arr2 = arr1;//传递的是地址值
        arr2[0] = 10;

        System.out.println(arr1[0]);//10
//2.2 对象类型
        Order order1 = new Order();
        order1.orderId = 1001;

        Order order2 = order1; //传递的是地址值
        order2.orderId = 1002;

        System.out.println(order1.orderId);//1002

    }
}

class Order {
    int orderId;
}

